const path = require('path');

function resolve (dir) {
  return path.join(__dirname, dir);
}

// const proxyTarget = 'https://usercenter-dev.bmw.com.cn';
const proxyTarget = 'http://127.0.0.1:7001';
// const isProd = process.env.NODE_ENV === 'production';

module.exports = {
  productionSourceMap: false,
  chainWebpack: config => {
    config.resolve.alias.set('@', resolve('src'));
  },
  devServer: {
    port: 8080,
    proxy: {
      '/system': {
        target: proxyTarget,
        ws: false,
        changeOrigin: true,
        logLevel: 'debug',
        pathRewrite: { '^/sys': '' }
      },
      '/common': {
        target: proxyTarget,
        ws: false,
        changeOrigin: true,
        logLevel: 'debug',
        pathRewrite: { '^/common': '' }
      },
      '/ui': {
        target: proxyTarget,
        ws: false,
        changeOrigin: true,
        logLevel: 'debug',
        pathRewrite: { '^/ui': '' }
      }
    }
  }
};
